The iridescent colours of soap bubbles are caused by interfering of (internally and externally) reflected light waves and are determined by the thickness of the film. This phenomenon is not the same as the origin of rainbow colours (caused by the refraction of internally reflected light), but rather are the same as the phenomenon causing the colours in an oil slick on a wet road.
As light impinges on the film
The total reflection observed is determined by the interference of all these reflections. Since each traversal of the film causes a phase shift proportional to the thickness of the film and inversely proportional to the wavelength, the result of the interference depends on these two quantities. So at a given thickness, interference is constructive for some wavelengths and destructive for others, so that white light impinging on the film is reflected with a hue that changes with thickness.
A change in colour can be observed while the bubble is thinning due to evaporation and draining. Thicker walls cancel out red (longer) wavelengths, causing a blue-green reflection. Later, thinner walls will cancel out yellow (leaving blue light), then green (leaving magenta), then blue (leaving a golden yellow). Finally, when the bubble's wall becomes much thinner than the wavelength of visible light, all the waves in the visible region cancel each other out and no reflection is visible at all. When this state is observed, the wall is thinner than about 25 nanometers, and is probably about to pop. This phenomenon is very useful when making or manipulating bubbles as it gives an indication of the bubble's fragility.
Interference effects also depend upon the angle at which the light strikes the film, an effect called iridescence. So, even if the wall of the bubble were of uniform thickness, one would still see variations of colour due to curvature and/or movement. However, the thickness of the wall is continuously changing as gravity pulls the liquid downwards, so bands of colours that move downwards are usually observed.